package lockOb;

public class AbThread extends Thread {

    char[] content = {'A', 'B'};
    int count = 0;

    @Override
    public void run() {
        synchronized (this) {
            try {
                while(count < 100) {
                    System.out.println(Thread.currentThread().getName() + ", " + content[count % 2] + ",count: " + (++count));
                    this.notify();
                    if (count < 100) {
                        this.wait();
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
